home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10225 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.sources.wanted,comp.lang.c,comp.unix.programmer
  4. Subject: Re: Seek unix2dos.c OR help with tr
  5. Date: Sat, 16 Mar 96 01:03:40 GMT
  6. Organization: none
  7. Message-ID: <826938220snz@genesis.demon.co.uk>
  8. References: <4i0946$7io@nuke.csu.net> <danpop.826545577@rscernix> <4i9dj4INN7kl@keats.ugrad.cs.ubc.ca> <4ia0kj$d8s@solutions.solon.com>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4ia0kj$d8s@solutions.solon.com>
  15.            seebs@solutions.solon.com "Peter Seebach" writes:
  16.  
  17. >In article <4i9dj4INN7kl@keats.ugrad.cs.ubc.ca>,
  18. >Kazimir Kylheku <c2a192@ugrad.cs.ubc.ca> wrote:
  19. >>When I know that I'm specifically dealing with ASCII control chars, I have a
  20. >>macro like:
  21. >
  22. >>#define CTRL(C) ((C)-64)
  23. >
  24. >>which I then use with capital letters:
  25. >
  26. >>       switch(char) {
  27. >>       case CTRL('M'):
  28. >
  29. >I always use
  30. >        #define CTRL(x) ((x) & 0x1f)
  31. >
  32. >because this preserves the likely semantics of CTRL.
  33.  
  34. Another common approach is:
  35.  
  36.          #define CTRL(x) ((x) ^ 64)
  37.  
  38. Since this maps ASCII ^? to 0x7f i.e. DEL.
  39.  
  40. -- 
  41. -----------------------------------------
  42. Lawrence Kirby | fred@genesis.demon.co.uk
  43. Wilts, England | 70734.126@compuserve.com
  44. -----------------------------------------
  45.